<!--
 * @Descripttion:
 * @version:
 * @Author: cxguo
 * @Date: 2020-06-15 17:45:55
 * @LastEditors: cxguo
 * @LastEditTime: 2020-08-20 07:37:34
-->
<template>
  <div class="app-container">
    <el-alert
      type="error"
      show-icon
    >
      <h2 slot="title">系统重置警告说明：</h2>
      <div>
        <h3>请仔细阅读如下条款，再进行操作：</h3>
        <p>
          1. 所有明细账、单据、基础资料将被删除！<br>
          2. 重置之后将不能查询重建以前的往来帐！<br>
          <!-- 3. 如需保留基础资料信息，请在重置前联系客服！<br> -->
        </p>
      </div>
    </el-alert>
    <div class="margin-t20">
      <el-checkbox v-model="dataObj.clear" disabled border>
        清除所有明细账及单据
      </el-checkbox>
      <el-checkbox v-model="dataObj.clear" disabled border>
        清除商品
      </el-checkbox>
      <el-checkbox v-model="dataObj.clear" disabled border>
        清除客户
      </el-checkbox>
      <el-checkbox v-model="dataObj.clear" disabled border>
        清除供应商
      </el-checkbox>
    </div>
    <div class="paddingTb20 text-center">
      <el-checkbox v-model="dataObj.isAllowNegStock">
        我了解并确认此功能将导致不可恢复的数据丢失，无须贵公司对此操作引发的数据丢失负责!
      </el-checkbox><br>
      <el-button
        size="medium"
        type="primary"
        :loading="loading"
        @click="btnSaveData"
      >确定</el-button>
    </div>
  </div>
</template>

<script>

import { clearAllData } from '@/api/sys/tenant.js'

export default {
  name: 'SysReset',
  data() {
    return {
      loading: false,
      dataObj: { isAllowNegStock: true }
    }
  },
  methods: {
    btnSaveData() {
      const isAllowNegStock = this.dataObj.isAllowNegStock
      if (!isAllowNegStock) return this.$message.error('请勾选选项！')
      this.loading = true
      clearAllData().then(res => {
        this.loading = false
        if (!res.data.flag) return this.$notify.error('重置失败！')
        this.$notify.success('重置成功！')
      }).catch(_ => {
        this.loading = false
      })
    }
  }
}
</script>

<style>

</style>
